Replace function not returning correct values